package com.Homework.test;

import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;

public class PrintOne {
    public void printone(String[] In, ArrayList<Yq> yq) throws IOException {

        int CountNum = 0;
        int count = In.length;
        for(int i = 0;i < yq.size(); i++)
        {
            if(yq.get(i).Province.equals(In[2])) {
                CountNum = yq.get(i).SumNum;
            }

        }
        try {
            FileWriter writer;
            writer = new FileWriter(In[1]);
            writer.write(In[count - 1] + " \t" + CountNum + '\n' );
            for(int i =0;i< yq.size() ;i++)
            {
                if (yq.get(i).Province.equals(In[2]))
                    writer.write(yq.get(i).City + " \t" + yq.get(i).Citynum + "\n");
            }
            writer.flush();
            writer.close();
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
